package cn.whale.task.fallback;

import cn.whale.basic.utils.JSONResult;
import cn.whale.task.api.PayResultToMQApi;
import cn.whale.task.domain.MqLog;
import cn.whale.task.to.MQLogStatusUpdateTo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

@Component
@Slf4j
public class PayResultToMQApiFallbackFactory implements FallbackFactory<PayResultToMQApi> {
    @Override
    public PayResultToMQApi create(Throwable throwable) {

        return new PayResultToMQApi() {

            @Override
            public JSONResult save(MqLog mqLog) {
                throwable.printStackTrace();
                log.error("服务降级 PayResultToMQApiFallbackFactory.PayResultToMQApi");
                return JSONResult.error("服务降级 PayResultToMQApiFallbackFactory.PayResultToMQApi");
            }

            @Override
            public JSONResult updateStatusForMqLog(MQLogStatusUpdateTo to ){
                throwable.printStackTrace();
                log.error("服务降级 PayResultToMQApiFallbackFactory.updateStatusForMqLog");
                return JSONResult.error("服务降级 PayResultToMQApiFallbackFactory.updateStatusForMqLog");
            }
        };
    }
}
